import logging

logformat="%(asctime)s - %(levelname)s - %(message)s"


def setupLogging(infologname,errlogname,bRestart=1):
    infoLogger=logging.getLogger("infologger")
    errLogger=logging.getLogger("errlogger")
    formatter=logging.Formatter(logformat)

    if(bRestart):
        infologhandler=logging.FileHandler(infologname,"a")
        errloghandler=logging.FileHandler(errlogname,"a")
    else:
        infologhandler=logging.FileHandler(infologname,"w")
        errloghandler=logging.FileHandler(errlogname,"w")

    infologhandler.setFormatter(formatter)
    errloghandler.setFormatter(formatter)
    infoLogger.setLevel(logging.INFO)
    errLogger.setLevel(logging.ERROR)
    infoLogger.addHandler(infologhandler)
    errLogger.addHandler(errloghandler)
    
    print 'log setup ok'
    return (infoLogger,errLogger)

def errLog(errLogger,strinfo):
    try:
        errLogger.error(strinfo)
    except Exception,e :
        pass

def infoLog(infoLogger,strinfo):
    try:
        infoLogger.info(strinfo)
    except Exception,e :
        pass

